package com.junyidao.game.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.junyidao.game.mapper.TAccountDetailMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by zzh on 2016/10/8.
 * 文件描述 ：
 */
@Service
@Transactional
public class AccountDetailService {

    @Autowired
    private TAccountDetailMapper accountDetailMapper;

    public Map<String, Object> getAccountChargeDay(String beginTime, String endTime, Integer uid, Integer puid, Integer page, Integer rows) {
        PageHelper.startPage(page, rows);
        Map<String, Object> map = new HashMap<>();
        map.put("beginTime", beginTime);
        map.put("endTime", endTime);
        map.put("uid", uid);
        map.put("puid", puid);
        List<Map<String, Object>> list = accountDetailMapper.getAccountChargeDay(map);
        Integer total = accountDetailMapper.getAccountChargeDayTotal(map);
        PageInfo pageInfo = new PageInfo(list);
        Map<String, Object> ret = new HashMap<>();
        ret.put("list", list);
        ret.put("total", total);
        ret.put("count", pageInfo.getTotal());
        return ret;
    }

    public Map<String, Object> getAccountChargeDetail(String beginTime, String endTime, Integer uid, Integer puid, Integer page, Integer rows) {
        PageHelper.startPage(page, rows);
        Map<String, Object> map = new HashMap<>();
        map.put("beginTime", beginTime);
        map.put("endTime", endTime);
        map.put("uid", uid);
        map.put("puid", puid);
        List<Map<String, Object>> list = accountDetailMapper.getAccountChargeDetail(map);
        Integer total = accountDetailMapper.getAccountChargeDayTotal(map);
        PageInfo pageInfo = new PageInfo(list);
        Map<String, Object> ret = new HashMap<>();
        ret.put("list", list);
        ret.put("total", total);
        ret.put("count", pageInfo.getTotal());
        return ret;
    }

}
